package com.kerrykidz.system.util.quartz;


import java.util.Date;
import java.util.List;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.kerrykidz.parreserve.dao.model.ParReserveEntity;
import com.kerrykidz.parreserve.dao.model.ParReserveRoomEntity;
import com.kerrykidz.parreserve.service.IParReserveService;
import com.kerrykidz.system.util.DateUtil;
import com.rdp.util.config.SpringUtil;

/**
 * 派对团体预约更改且有锁定房间的，超过2小时未完成预付，锁定房间释放 每10分钟执行一次
 * ParReserveQuartz
 * @author rain
 *
 */
public class ParReserveRoomQuartz extends QuartzJobBean {
	protected void executeInternal(JobExecutionContext arg0)
			throws JobExecutionException {
		 try {  
			 IParReserveService parReserveService = SpringUtil.getBeanByType(IParReserveService.class);
			 List<ParReserveRoomEntity> parReserveRoomList= parReserveService.parResRoomCancelLocalFlag();
			 if(null !=parReserveRoomList && parReserveRoomList.size()>0){
				 for(ParReserveRoomEntity parReserveRoom:parReserveRoomList){
					 String parReserveId=parReserveRoom.getFkParresId();
					 ParReserveEntity parReserve =new ParReserveEntity();
					 parReserve.setPkParresId(parReserveId);
					 parReserve.setModiTime(new Date());
					 parReserveService.updateParReserve(parReserve);
					 
					 parReserveRoom.setLockFlag("0");
					 parReserveService.updateParReserveRoom(parReserveRoom);
				 }
			 }
			 
			 parReserveService.updateParReserveFKCancel();
        } catch (Exception e) {  
            e.printStackTrace();  
        } 
	}


 
	
	 
}
